<?php

    require_once($application_folder."/controllers/navigator.php");
    class Poll extends navigator 
    {
        var $data = array();

        function Poll () 
        { 
            parent::navigator();
            $this->load->model('anketa_m','anketa');  
        }

        function readpoll() 
        {  
            echo $_GET['jsoncall'] . '(' . json_encode($this->anketa->readpoll() ) . ');';
        } 

        function readquestion() 
        {  
            echo $_GET['jsoncall'] . '(' . json_encode($this->anketa->readquestion() ) . ');';
        }

        function readpolloptions() 
        {  
            echo $_GET['jsoncall'] . '(' . json_encode($this->anketa->readpolloptions() ) . ');';
        }    

        function readall(){
            $poll = array (
            'a'=>$this->anketa->readpoll(),
            'b'=>$this->anketa->readquestion(),
            'c'=>$this->anketa->readpolloptions()
            );

            echo $_GET['jsoncall'] . '(' . json_encode( $poll ) . ');';
        }
        
        function vote_radio()
        {
            $this->anketa->vote('radio');
        }
        function vote_checkbox()
        {
            $this->anketa->vote('checkbox');
        }
        
        function vote_results(){
            echo $_GET['jsoncall'] . '(' . json_encode($this->anketa->vote_results() ) . ');';            
        }
    }

?>
